#include<iostream>




class Complex
{
    public:
        Complex():real(0),vir(0){}
        Complex(int real,int vir):real(real),vir(vir){}
        

        Complex operator+(const Complex&c);
        
        Complex operator-(const Complex &c);
        
        //++a  自己本身就是参数 不用占位
        Complex& operator++();


        // a++ 需要有个占位
        Complex operator++(int);




        // void operator<<(std::ostream &os);
        // friend void operator<<(std::ostream &os,const Complex&c);
        friend std::ostream & operator<<(std::ostream &os,const Complex&c);

        friend std::istream& operator>>(std::istream &os, Complex&c);
    private:
        int real; //实部
        int vir;  //虚部
};





Complex Complex::operator+(const Complex &c)
{
    Complex result;
    result.real = this->real +c.real;
    result.vir = this->vir +c.vir;
    return result;
}

Complex Complex::operator-(const Complex &c)
{
    Complex result;
    result.real = this->real -c.real;
    result.vir = this->vir -c.vir;
    return result;
}


//占位参数
// ++a 
Complex& Complex::operator++()
{
    real++;
    vir++;
    return *this;
}
//  a++

Complex Complex::operator++(int)
{
    Complex result = *this;
    real++;
    vir++;
    
    return result;
}

// //不能作为成员函数重载：写法和一般习惯不同
// void Complex::operator<<(std::ostream &os)
// {
//     std::cout << real << "+" << vir << "i" << std::endl;
// }



// 全局重载
// void operator<<(std::ostream &os,const Complex&c)
// {
//     std::cout << c.real << "+" << c.vir << "i" << std::endl;
// }

std::ostream& operator<<(std::ostream &os,const Complex&c)
{
    os <<c.real << "+" << c.vir << "i" << std::endl;
    return os;
}

std::istream& operator>>(std::istream &is, Complex&c)
{
   is>>c.real>>c.vir;
    return is;
}

int main()
{
    Complex c(1,2);
    Complex c1 = ++c;
    
    
    // Complex c1(2,3);
    
    // c.show();
    // c1.show();
    // Complex c2 = c - c1;
    // c2.show();
    
    // c<<std::cout;



    // operator<<(std::cout,c);
    // std::cout<<c;


    std::cout<<c<<c1<<std::endl;

    std::cin>>c>>c1;
    
    std::cout<<c<<c1;



    return 0;
}
